<!DOCTYPE html>

<html>
    <head>
        <meta charset=UTF-8 />
        <title>AvatarBG Sample | TM Life</title>
        <style>
            * {
                margin: 0;
                padding: 0;
            }
        </style>
        <script src="lib/enchant.js/enchant.js"></script>
        <script src="lib/enchant.js/plugins/avatar.enchant.js"></script>
        <script>
            enchant();
            
            // リソース
            var IMAGE_PATH      = "lib/enchant.js/images/";
            var BG1 = IMAGE_PATH + "avatarBg1.png";
            var BG2 = IMAGE_PATH + "avatarBg2.png";
            var BG3 = IMAGE_PATH + "avatarBg3.png";
            var RESOURCE = [ BG1, BG2, BG3, ];
            
            game = null;
            
            window.onload = function() {
                // var mode = 1;
                var mode = document.location.search.substr(1);  // クエリで背景モードを指定
                    
                // ゲームクラス生成
                game = new Game();
                game.preload(RESOURCE);
                
                // 初期化
                game.onload = function() {
                    var scene = game.rootScene;
                    scene.backgroundColor = "#aaa";
                    
                    // 背景を無理矢理対応
                    for (var i=1; i<=3; ++i)
                        game.assets["avatarBg"+i+".png"] = game.assets[IMAGE_PATH + "avatarBg"+i+".png"];
                    
                    // AvatarBG
                    var bg = new AvatarBG(mode);
                    scene.addChild(bg);
                    bg.y = 50;
                };
                
                game.start();
            };
        </script>
    </head>
    <body>
        
    </body>
</html>